import onnx

def analyze(onnxfile, **kwargs):
    model = onnx.load(onnxfile)

    for idx in range(len(model.graph.input)):
        dim_proto_input = model.graph.input[idx].type.tensor_type.shape.dim[0]
        if dim_proto_input.dim_value != -1:
            return False

    for idx in range(len(model.graph.value_info)):
        dim_proto_input = model.graph.value_info[idx].type.tensor_type.shape.dim[0]
        # dim_proto_input.dim_param = 'bs'
        if dim_proto_input.dim_value != -1:
            return False   

    for idx in range(len(model.graph.output)):
        dim_proto_output = model.graph.output[idx].type.tensor_type.shape.dim[0]
        # dim_proto_output.dim_param = 'bs'
        if dim_proto_output.dim_value != -1:
            return False

    ### for Reshape
    reshape_param = []
    for node_id, node in enumerate(model.graph.node):
        #print(node_id, ", name:", node.name, ", input:", node.input, ", output:", node.output,  \
        #         ", op:", node.op_type, ', len(input):', len(node.input))
        if node.op_type == 'Reshape':
            print('Reshape, input:', node.input)
            if node.input[1] not in reshape_param:
                reshape_param.append(node.input[1])

    for n in reshape_param:
        for init in model.graph.initializer:
            if n == init.name:
                print('got it in initializer:', n)
                if init.int64_data[0] != -1:
                    return False      

    return True